﻿using System;
using System.Net;

namespace Cn.Soncy.Taotao
{
    /*
     * --------------------------------
     * FileName: TaotaoPost.cs
     * Description: 滔滔信息类,返回用户所发布的滔滔信息
     * 
     * Author: Soncy
     * DateTime: 2008-11-27
     * E-mail: soncy@163.com
     * --------------------------------
     */

    /// <summary>
    /// 滔滔信息类,返回用户所发布的滔滔信息
    /// </summary>
    public class TaotaoPost
    {
        /// <summary>
        /// @对方滔滔ID
        /// </summary>
        public string pid { get; set; }

        /// <summary>
        /// @对方QQ
        /// </summary>
        public int pqq { get; set; }

        /// <summary>
        /// @对方昵称
        /// </summary>
        public string pnm { get; set; }

        /// <summary>
        /// 发布人的滔滔QQ号码
        /// </summary>
        public string qq { get; set; }

        /// <summary>
        /// 发布人的滔滔昵称
        /// </summary>
        public string nm { get; set; }

        /// <summary>
        /// 滔滔内容
        /// </summary>
        public string cn { get; set; }

        /// <summary>
        /// 滔滔文章ID
        /// </summary>
        public string id { get; set; }

        /// <summary>
        /// 发布滔滔类型: '网页','QQ机器人','QQ空间','QQ签名','短信','手机上网','MSN机器人','MSN签名','手机QQ','彩信','订阅',"",'QQ状态'
        /// </summary>
        public int sr { get; set; }

        /// <summary>
        /// 发布滔滔类型(中文)
        /// </summary>
        public string publishType
        {
            get
            {
                string[] publicTypes = new string[] { "网页", "QQ机器人", "QQ空间", "QQ签名", "短信", "手机上网", "MSN机器人", "MSN签名", "手机QQ", "彩信", "订阅", "", "QQ状态" };

                return publicTypes[sr];
            }
        }

        /// <summary>
        /// 发布日期, 以逗号分割, 
        /// </summary>
        public string time { get; set; }

        /// <summary>
        /// 发布日期, 输出滔滔时间格式(...[秒,分钟,小时,1天,3天,1周]前)
        /// </summary>
        public string fulltime
        {
            get 
            {
                string[] dateType = new string[]{ "", "秒","分钟","小时","1天","3天","1周" };
                string[] dateTime = this.time.Split(','); 
                int type  = int.Parse(dateTime[0]);
                string datetime = dateTime[1];
                
                if(type<=3){
                    return datetime + dateType[type] + "前";
                }
                else if (type > 3 && type <= 6)
                {
                    return dateType[type] + "前";
                }
                else
                {
                    return datetime;
                }
            }
        }
    }
}
